Home > Java Programming > Objects and Collections > Questions and Answers
Exercise:
01. |
What will be the output of the program? public class Test { public static void main (String args[]) { String str = NULL; System.out.println(str); } } | |||||||||||
|
02. |
What will be the output of the program? public class Test { private static int[] x; public static void main(String[] args) { System.out.println(x[0]); } } | |||||||||||
|
03. | Which class does not override the equals() and hashCode() methods, inheriting them directly from class Object? | |||||||||||
|
04. | Which interface does java.util.Hashtable implement? | |||||||||||
|
05. |
What two statements are true about properly overridden hashCode() andequals() methods? 1. hashCode() doesn't have to be overridden if equals() is. 2. equals() doesn't have to be overridden if hashCode() is. 3. hashCode() can always return the same value, regardless of the object that invoked it. 4. equals() can be true even if it's comparing different objects. | |||||||||||
|
06. | Which statement is true for the class java.util.ArrayList? | |||||||||||
|
07. |
class W{ Public static void main(String args[]){ Int i=10; Method(i); } Static void method(Object o){ System.out.println(“objectâ€); } Static void method(Number n){ System.out.println(“numberâ€); } } | |||||||||||
|
08. |
class W{ Static void method(int I,int j ){ System.out.println(“intâ€); } Static void method(byte…b){ System.out.println(“byteâ€); } Public static void main(String args[]){ byte i=10; method(i,i); } } | |||||||||||
|
09. |
class W{ Static void method(Byte I,Byte j ){ System.out.println(“BByteâ€); } Static void method(byte…b){ System.out.println(“byteâ€); } Public static void main(String args[]){ byte i=10; method(i,i); } } | |||||||||||
|
10. |
class W{ Static void method(Byte I,Byte I ){ System.out.println(“BByteâ€); } Static void method(byte…b){ System.out.println(“byteâ€); } Public static void main(String args[]){ byte i=10; method(i,i); } } | |||||||||||
|
11. |
Class A{ Class B{ Int I; } public static void main(String args[]){ B b1=new B(); System.out.println(b1.i); } } | |||||||||||
|